
import grails.test.*

class RoleControllerTests extends ControllerUnitTestCase {
    protected void setUp() {
        super.setUp()
		println "RoleControllerTests"
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testIndexAction() {
		controller.index()
		
		assertEquals "list", redirectArgs["action"]
    }
	
	void testListAction() {
		
		// Prepare data
		def Role ra = new Role(roleName: "Admin")
		def Role rb = new Role(roleName: "Guest")
		mockDomain(Role, [ra, rb])
		ra.save()
		rb.save()
		
		assertEquals 2, Role.count()
		
		// Prepare session
		controller.session.userId = "admin"
		def resultMap = controller.list()
		
		assertNotNull resultMap
		assertEquals 2, resultMap.roleList.size()
		assertEquals 2, resultMap.roleTotal
	}
	
	void test() {
		// TODO more and more test cases
	}
}
